{% extends 'LimsMainBundle::Layout/formLayout.html.twig' %}

{% block stylesheets %}
    {{ parent() }}
{% endblock %}

{% block javascripts %}
    {{ parent() }}
    <script type="text/javascript" src="/template/js/plugins/flot/jquery.flot.js"></script>
    <script type="text/javascript" src="/template/js/plugins/flot/jquery.flot.resize.js"></script>
    <script type="text/javascript" src="/template/js/plugins/flot/jquery.flot.time.js"></script>
    <script type="text/javascript" src="/template/js/lims/addPayment.js"></script>
    
{% endblock %}

{% block content %}

    {% include 'LimsMainBundle::Breadcrumb/breadcrumb.html.twig' with {'breadCrumbName' : 'Зээл төлөлт'} %} 
    
    <div class="row"> 
        <div class="col-md-5">
            <div class="block">
                <div class="header"> 
                    <h2>Зээл хайх</h2>                     
                </div>    
                <div class="content controls">
                    <div class="form-row" id="searchContractContainer"> 
                        <div class="col-md-3">Гэрээний дугаар оруулана уу : </div> 
                        <div class="col-md-9 padding-right-none"> 
                            <input type="text" name="paymentSearch" id="paymentSearch" value="{{contractId}}">
                        </div> 
                    </div>
                        
                    <div id="info_container" style="display: none;"> 
                        <div class="block block-drop-shadow"> 
                            <div class="header"> <h2>Зээлдэгчийн мэдээлэл</h2> </div> 
                            <div class="content np"> 
                                <div id="inquiryListWrapper" class="list list-contacts">
                                    <div class="list-item">
                                        <div class="col-md-3">
                                            <div style="min-height: 112px;margin-right:20px;">
                                                <div class="list-info"> 
                                                    <img src="/template/img/user.jpg" class="img-circle img-thumbnail"> 
                                                </div>
                                                
                                            </div>
                                        </div>
                                        <div class="col-md-9">
                                            <div class="list-text"> 
                                                    <b><span class="list-text-name" id="info_name"></span></b>
                                                    <i><div class="list-text-info">Овог : <span id="info_family_name"></div></i>
                                                    <i><div class="list-text-info">Утас : <span id="info_phone"></span></div></i>
                                                    <i><div class="list-text-info">И-мэйл : <span id="info_email"></span></div></i>
                                            </div>
                                        </div>
                                    </div>
                                </div> 
                            </div> 
                        </div>
                    </div>
                </div>
            </div>            
        </div>
        <div class="col-md-7"> 
            
            <div class="block block-transparent" id="paymentGraphContainer" style="display: none">
                <div class="header">
                    <h2>Төлөлтийн график</h2>
                </div>
                <br/>
                <div class="content">
                    <div id="payment_chart" style="width:100%;height:250px"></div>
                </div>                
            </div>
            
        </div>
    </div>
    
                            <form action="{{path('lims_payment_save')}}" method="post" name="add_payment" id="add_payment" onkeypress="return event.keyCode != 13;" autocomplete="off">
        <div class="row" style="display: none;" id="paymentTableContainer"> 

            <div class="col-md-12">

                    <div class="block"> 
                        <div class=header> <h2>Зээлийн төлөлт</h2> </div>
                        <div class="content controls">
                            <div class="col-md-4 padding-none">
                                    <div class="block block-white">                                 
                                <div class="content">                                                         
                                    <table class="table text-align-right">
                                        {#<thead>
                                            <tr>
                                                <th colspan="2">Зээлийн нөхцөл</th>
                                            </tr>
                                        </thead>#}
                                        <tbody>
                                            <tr>
                                                <td>Зээлийн хэмжээ</td>
                                                <td><span id="schedule_total_amount"></span></td>
                                            </tr>
                                            <tr>
                                                <td>Жилийн хүү</td>
                                                <td><span id="schedule_intereset"></span>%</td>
                                            </tr>
                                            <tr>
                                                <td>Зээлийн хугацаа /сар/</td>
                                                <td><span id="schedule_length"></span></td>
                                            </tr>
                                            <tr>
                                                <td>Зээл эхлэх огноо</td>
                                                <td><span id="schedule_start_date"></span></td>
                                            </tr>
                                            <tr>
                                                <td>Эхний төлбөр хийх огноо</td>
                                                <td><span id="schedule_payment_start_date"></span></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>                                                     
                            </div>

                            <div class="block block-white">                                                     
                                <div class="content">                                                         
                                    <table class="table text-align-right">                                                            
                                        <tbody>
                                            <tr>
                                                <td>Төлбөрийн хэлбэр</td>
                                                <td><span id="schedule_payment_type"></span></td>
                                            </tr>
                                            <tr>
                                                <td>Сард төлөгдөх дүн</td>
                                                <td><b><span id="schedule_amount_per_unit"></span></b></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>                                                     
                            </div>
                            </div>
                            <div class="col-md-8" style="padding-right: 0px;">
                                <table class="table table-bordered margin-top-10" id="schduleTable"> 
                                    <thead> 
                                        <tr> 
                                            <th width="5%">#</th>                                                             
                                            <th width="15%">Огноо</th> 
                                            <th width="5%">Хоног</th> 
                                            <th width="15%">ҮЗ төлбөр</th> 
                                            <th width="15%">Хүү төлбөр</th> 
                                            <th width="15%">Нийт төлбөр</th> 
                                            <th width="15%">Төлөлт</th>
                                            <th width="15%">Зээлийн үлдэгдэл</th>                                            
                                        </tr> 
                                    </thead> 
                                    <tbody id="schduleTbody"> 

                                    </tbody>
                                </table>
                                <input type="hidden" id="hiddenScheduleRowNum" value="0" />
                            </div>
                        </div>
                    </div>
            </div>
        </div>
        <div class="row">
            <div class=footer> 
                <div class="side"> 
                    <div class="btn-group margin-left-10">                         
                        <button class="btn btn-success" name="save" value="1" type="submit" id="submitBtn" style="display: none;">Хадгалах</button> 
                    </div> 
                </div> 
            </div> 
        </div>
        <input type="hidden" name="creditId" id="creditId" value=""/>
        <input type="hidden" name="contractId" id="contractId" value=""/>
        <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
    </form>



{% endblock %}